home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5884 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.3 KB  |  51 lines

  1. Newsgroups: comp.lang.c
  2. Path: undergrad.math.uwaterloo.ca!clgonsal
  3. From: clgonsal@undergrad.math.uwaterloo.ca (Carl Laurence Gonsalves)
  4. Subject: Re: Tradition or what?
  5. Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
  6. Message-ID: <Dn4wML.5LJ@undergrad.math.uwaterloo.ca>
  7. Date: Wed, 21 Feb 1996 16:32:44 GMT
  8. References: <4g0elg$mdr@redstone.interpath.net>
  9. Nntp-Posting-Host: cayley.uwaterloo.ca
  10. Organization: University of Waterloo
  11.  
  12. In article <4g0elg$mdr@redstone.interpath.net>,
  13. Scott McMahan - Softbase Systems <softbase@mercury.interpath.net> wrote:
  14. >Erik van Renselaar writes:
  15. >
  16. >: Can anyone tell me what the use is of returning
  17. >: the same value for the function and one of the
  18. >: output parameters, like it is done in strcpy?
  19. >
  20. >Steve Maguire discusses this issue in Writing Solid Code.  The
  21. >randomness with which the C library's parameters and return code
  22. >(0=success AND failure depending on the function!) conventions happened
  23. >are bad because they influence people who look upon them as models.
  24. >Reading Writing Solid Code is almost mandatory.
  25.  
  26. I read both "Writing Solid Code" and "Code Complete". I found Code
  27. Complete to be much better, and it covered a lot of the same stuff as
  28. Writing Solid Code. Most of what  CC didn't cover that WSC did cover I
  29. found to be either obvious, or silly. It was also interesting to note that
  30. there are some points on which the two authors are diametrically opposed.
  31.  
  32. The inconsistent return types/parameters of the ANSI C library are pretty
  33. obvious simply because they're so annoying. The most irritating example I
  34. can think of is the stdio functions that take a FILE*. Most take it as the
  35. first parameter, but a few take it as the *last* parameter. Argh!
  36.  
  37. As for strcpy, etc, returning the same pointer you pass them, this might
  38. also be useful for writing code in a "lisp-like" way. For instance:
  39.  
  40. strcat( strcpy( a, b ), c );
  41.  
  42. This copies b to a and that concatenates c onto the end of a. Certainly not
  43. recommended unless you're absolutely positive you're not going to get a
  44. NULL in there somewhere.
  45.  
  46. -- 
  47.         Carl Laurence Gonsalves - clgonsal@undergrad.math.uwaterloo.ca
  48.                    Computer Science, University of Waterloo
  49.                http://www.undergrad.math.uwaterloo.ca/~clgonsal/
  50.                    http://www.csclub.uwaterloo.ca/~clgonsal/
  51.